package com.yyjj.hangqing.adapter.viewpager;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Desc:
 */
public class ViwPagerTitleAdapter extends FragmentPagerAdapter{
    List<String> titles;
    List<Fragment> hqingfragmentList = new ArrayList<>();

    public ViwPagerTitleAdapter(FragmentManager fm, List<String> titles, List<Fragment> hqingfragmentList) {
        super(fm);
        this.titles = titles;
        this.hqingfragmentList = hqingfragmentList;
    }

    @Override
    public Fragment getItem(int i) {
        return hqingfragmentList.get(i);
    }

    @Override
    public int getCount() {
        return titles==null?0:titles.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
